package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.property.PropertyProjectExportAddressesDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyProjectSaveImportAddressDTO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectRoomInfoVO;
import com.itlong.cloud.project.property.IPropertyAddressInfoServiceClient;
import com.itlong.cloud.property.service.IPropertyAddressInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <desc>
 *      地址信息服务暴露接口实现类（如导入、导出）.
 * </desc>
 *
 * @createDate 2017-09-22
 */
@RestController
public class PropertyAddressInfoServiceResource implements IPropertyAddressInfoServiceClient {

    @Autowired
    private IPropertyAddressInfoService iPropertyAddressInfoService;  //地址信息处理接口

    /**
     * <desc>
     *      保存通过Excel文件导入的地址信息
     * </desc>
     * @param propertyProjectSaveImportAddressDTO 从Excel(*.xls)导入地址信息数据传输对象(含楼栋列表、单元列表、房间列表,用于保存到数据库)
     * @return 受影响的行数
     * @author LouisLewis
     * @createDate 2017-10-12
     */
    @Override
    @RequestMapping(path = "property/addressInfo/saveImportAddressInfo",method = {RequestMethod.POST})
    public Integer saveImportAddressInfo(@RequestBody PropertyProjectSaveImportAddressDTO propertyProjectSaveImportAddressDTO) throws Exception{
        return iPropertyAddressInfoService.saveImportAddressInfo(propertyProjectSaveImportAddressDTO)  ;
    }

    /**
     * <desc>
     *      按楼栋Id列表查询房间信息(用于导出)
     * </desc>
     *
     * @param propertyProjectImportAddressExtraDataDTO 导出地址信息到Excel(*.xls)数据传输对象
     * @return 房屋信息列表
     * @author LouisLewis
     * @createDate 2017-10-16
     */
    @Override
    @RequestMapping(path = "property/addressInfo/getExportAddressInfo",method = {RequestMethod.POST})
    public List<PropertyProjectRoomInfoVO> getExportAddressInfo(@RequestBody PropertyProjectExportAddressesDTO propertyProjectImportAddressExtraDataDTO) {
        return iPropertyAddressInfoService.getExportAddressInfo(propertyProjectImportAddressExtraDataDTO);
    }
}
